﻿using System;
using System.Collections.Generic;
using TopBuilds.Restaurant.Data;

namespace TopBuilds.Restaurant.ViewModel
{
    public sealed class PrintRemoteCollection : System.Collections.ObjectModel.ObservableCollection<PrintRemote>
    {
         private string _condition;

         public string Condition
         {
             get { return _condition; }

             set
             {
                 if (_condition != null && _condition == value)
                 {
                     return;
                 }

                 _condition = value;

                 if (Count > 0)
                 {
                     base.Clear();
                 }

                 PrintRemote[] list = PrintRemoteObject.GetPrintRemotes();
                 if (list != null)
                 {
                     foreach (PrintRemote item in list)
                     {
                         Add(item);
                     }
                 }
             }
         }

         public PrintRemoteCollection()
        {
            Condition = null;
        }

         public PrintRemote GetPrintRemote(int printRemoteId)
         {
             foreach (PrintRemote printRemote in this)
             {
                 if (printRemote.Id == printRemoteId)
                 {
                     return printRemote;
                 }
             }

             return null;
         }

    }
}
